<template>
  <div class="cooperativeModel">
    <zy-model :show="show" type="table" :is-show-submit="false" @close="close" width="1200">
      <div class="model-table-box">
        <zy-title>合作站点列表</zy-title>
        <!--    筛选条件-->
        <div class="search-box">
          <div class="search-item">
            <div class="search-label">企业名称</div>
            <zy-input v-model="form.company_name" placeholder="请输入企业名称" :clearable="true"></zy-input>
          </div>
          <div class="search-item">
            <div class="search-label">统一社会信用代码</div>
            <zy-input v-model="form.organization_code" placeholder="请输入统一社会信用代码" :clearable="true"></zy-input>
          </div>
          <div class="search-item">
            <div class="search-label">法人姓名</div>
            <zy-input v-model="form.legal_person" placeholder="请输入法人姓名" :clearable="true"></zy-input>
          </div>
          <div class="search-item">
            <div class="search-label">法人联系方式</div>
            <zy-input v-model="form.legal_phone" placeholder="请输入法人联系方式" :clearable="true"></zy-input>
          </div>
          <div class="search-item">
            <div class="search-label">法人身份证</div>
            <zy-input v-model="form.legal_card_no" placeholder="请输入法人身份证" :clearable="true"></zy-input>
          </div>
          <div class="search-item">
            <div class="search-label">注册时间</div>
            <datePicker v-model="registration_date"></datePicker>
          </div>
          <div class="btnArea">
            <zy-button @click="getData(true)">重置</zy-button>
            <zy-button @click="getData(false)" type="primary">查询</zy-button>
          </div>
        </div>
        <!--    列表-->
        <div class="table_list" ref="table_list">
          <el-table :data="tableData" :loading="personnelLoading">
            <el-table-column type="index" label="序号" width="100"></el-table-column>
            <el-table-column prop="company_name" label="合作站点名称"></el-table-column>
            <el-table-column prop="organization_code" label="统一社会信用代码" ></el-table-column>
            <el-table-column prop="legal_person" label="法人姓名"></el-table-column>
            <el-table-column prop="legal_phone" label="法人联系方式"></el-table-column>
            <el-table-column prop="legal_card_no" label="法人身份证号"></el-table-column>
            <el-table-column prop="create_time" label="创建时间"></el-table-column>
          </el-table>
        </div>
        <div class="paging">
          <el-pagination background layout="total, sizes,prev, pager, next,jumper" :page-sizes="[10, 20, 30, 50]"
                         @size-change="(page_size) => {this.form.page_size = page_size;this.getData()}"
                         @current-change="(page_size) => {this.form.page_start = page_size;this.getData()}"
                         :page-size="form.page_size" :total="total" :current-page="form.page_start"></el-pagination>
        </div>
      </div>
    </zy-model>
  </div>
</template>

<script>
	import datePicker from "../../../../components/datePicker/index";

	export default {
		name: "cooperativeModel",
		props: {	show: {
				type: Boolean,
				default: () => false
			},
			regulated_id:{
				type: String,
				default: () => ''
      }
		},
		data() {
			return {
				form: {
					company_name: '',
					organization_code: '',
					legal_person: '',
					legal_phone: '',
					legal_card_no: '',
					start_created_time:'',
					end_created_time:'',
					company_type: 2,
					page_start: 1,
					page_size: 10
				},
				registration_date: [],
				personnelLoading: false,
				tableData: [],
				total: 0,
			};
		},
		computed: {},
		watch: {
			show(newVal){
				if(newVal)
					this.getData();
			}
    },
		components: {datePicker},
		methods: {
			getData(isReset) {
				if (isReset) {
					this.form = {
						company_name: '',
						organization_code: '',
						legal_person: '',
						legal_phone: '',
						legal_card_no: '',
						start_created_time:'',
						end_created_time:'',
						company_type: 2,
						page_start: 1,
						page_size: 10
					}
					this.registration_date=[];
				}
				if (this.registration_date && this.registration_date.length > 0) {
					this.form.start_created_time = this.registration_date[0] / 1000;
					this.form.end_created_time = this.registration_date[1] / 1000;
				}
				this.personnelLoading = true;
				this.tableData = [];
				this.$axios.post(this.$api.g_companyList, {...this.form,regulated_id:this.regulated_id}).then(res => {
					let {code, msg, data} = res;
					this.personnelLoading = false;
					if (code == 200) {
						if (data.list && data.list.length > 0) {
							this.tableData = data.list.filter(item => {
								return item;
							});
						}
						this.total = data.pagination.total_count || 0;
					} else {
						this.total = 0
						this.tableData = [];
					}
				})
					.catch(ret => {
						this.$message.error(ret.msg || "服务繁忙，请稍后再试");
					});
			},
			close() {
				this.$emit('close','coop')
			},
		},
		mounted() {
		},
		created() {
		}
	}
</script>

<style scoped lang="less">
  @import "../../../../style/common/common";

  @thBgColor: #F0F0F0;
  @boxShadowColor: rgba(0, 0, 0, 0.1);
  .model-table-box {
    .zy-title {
      padding: 0 @commonPaddingOutside;
      margin-bottom: @commonPaddingOutside;

      .page-title {
        display: flex;
        justify-content: space-between;
        align-items: center;
      }
    }
    .zy-title::after {
      top: 0;
      bottom: 0
    }

    .search-box {
      display: flex;
      align-items: center;
      flex-wrap: wrap;
      padding: 0 @commonPaddingOutside;
      margin-bottom: @commonPaddingOutside;

      .search-item {
        display: flex;
        align-items: center;
        flex: 0 0 33.334%;
        margin-bottom: @commonPaddingOutside;

        .search-label {
          font-size: 14px;
          color: @fontColor;
          margin-right: 8px;
          flex: 0 0 60px;
        }

        .zy-input, .el-select, .date-picker {
          flex: 0 0 260px;
          height: 40px;
          border-radius: 4px;

          .el-input__inner {
            flex: 1;
            background: rgba(216, 216, 216, 0);
            border-radius: 4px;
            border: 1px solid #C7CBD1;
            color: @fontColor;
          }
        }
      }

      .search-item:nth-child(3n+2) {
        justify-content: center;
      }

      .search-item:nth-child(3n+3) {
        justify-content: flex-end;
      }


      .btnArea {
        display: flex;
        justify-content: flex-end;
        align-items: center;
        width: 100%;
        button {
          margin-left: 28px;
        }
      }
    }

    .table_list {
      margin-bottom: @commonPaddingOutside;
      max-height: 360px;
      overflow-y: auto;

      /deep/ .el-table__empty-text {
        min-height: 46px;
      }

      /deep/ .el-table .cell.el-tooltip > div {
        white-space: nowrap;
        text-overflow: ellipsis;
        overflow: hidden;
      }

      /deep/ .el-table th {
        height: 48px;
        font-size: 14px;
        font-weight: bold;
        color: @fontColor;
        background: @thBgColor;
      }

      /deep/ .el-table tr {
        height: 46px;
        color: @fontColor;
      }

      /deep/ .el-table__body tr.hover-row.current-row > td,
      /deep/ .el-table__body tr.hover-row.el-table__row--striped.current-row > td,
      /deep/ .el-table__body tr.hover-row.el-table__row--striped > td,
      /deep/ .el-table__body tr.hover-row > td {
        background-color: rgba(0, 119, 251, 0.2);
      }

      /deep/ .el-table tr:nth-child(odd) {
        background: @allWhite;
      }

      /deep/ .el-table tr:nth-child(even) {
        background: #f0f0f0;
      }

      /deep/ .el-table td, .el-table th.is-leaf {
        border-color: @borderColor;
      }

      /deep/ .el-table td.is-align-left {
        box-shadow: -1px 0px 1px 0px rgba(0, 0, 0, 0.1);
        background-color: @allWhite !important;
      }

      /deep/ .el-table td.is-align-left {
        box-shadow: -1px 0px 1px 0px rgba(0, 0, 0, 0.1);
        background-color: @allWhite !important;
      }

      /deep/ .el-table td.handler {
        box-shadow: -1px 0px 1px 0px rgba(0, 0, 0, 0.1);
        background-color: @allWhite !important;
      }
    }

    .paging {
      text-align: center;
      margin-top: 16px;

      /deep/ .el-pagination {
        color: @fontColor;

        /deep/ .el-pagination__total {
          font-size: 12px;
          color: @fontColor;
        }

        /deep/ .el-pagination__sizes {
          font-size: 12px;
          color: @fontColor;
        }

        /deep/ .el-input__inner {
          border: 1px solid #C7CBD1;
          color: @fontColor;
          border-radius: 4px;
          font-size: 12px;
        }

        /deep/ .el-pager li {
          font-size: 12px;
          font-weight: normal;
        }

        /deep/ .el-pager li.active {
          background-color: @allPrimaryColor;
        }
      }
    }
  }
</style>
